<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{include :: header('日志列表')}"/>
<th:block th:insert="~{include :: bootstrap-select-css}"/>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="log-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label for="codes">指令：</label><select class="form-select form-select-sm" name="codes" id="codes"
                                                        th:with="type=${code}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}"
                                    th:text="${#strings.replace(dict.getStr(),'^','').replace('$','').trim()}"
                                    th:value="${dict}"></option>
                        </select>
                        </li>
                        <li>
                            <label for="groupUid">群组： </label><input class="form-control" name="groupUid" placeholder="QQ群" id="groupUid"
                                                        type="text"/>
                        </li>
                        <li>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="searchPre()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:insert="~{include :: footer}"/>
<th:block th:insert="~{include :: bootstrap-select-js}"/>
<script th:inline="javascript">
    const prefix = ctx + "log/info";

    $(function () {
        const options = {
            url: prefix + "/list",
            cleanUrl: prefix + "/clean",
            detailUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            queryParams: queryParams,
            sortOrder: "desc",
            modalName: "日志",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [{
                field: 'state',
                checkbox: true
            },
                {
                    field: 'id',
                    title: '日志编号'
                },
                {
                    field: 'title',
                    title: '模块名称'
                },
                {
                    field: 'codes',
                    title: '指令'
                },
                {
                    field: 'botUid',
                    title: '机器人QQ'
                },
                {
                    field: 'groupUid',
                    title: 'QQ群'
                },
                {
                    field: 'userUid',
                    title: '触发者QQ'
                },
                {
                    field: 'runTime',
                    title: '操作时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row) {
                        const actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详细</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        return $.table.queryParams(params);
    }

    function searchPre() {
        $.table.search('log-form', 'bootstrap-table');
    }

    function resetPre() {
        $("#log-form")[0].reset();
        $.table.search('log-form', 'bootstrap-table');
    }
</script>
</body>
</html>